package org.etom.connector.datatypes;

import java.io.File;
import java.io.InputStream;

import org.etom.connector.service.ConnectorException;

/**
 * The Moodle module represents resources
 * and assignments on the server.
 */
public interface IMoodleModule {
  
  /** The resource type represents a data file. */
  public static final int RESOURCE   = 0x01;
  
  /** The assignment type represents a upload form for data file */
  public static final int ASSIGNMENT = 0x02;
  
  /**
   * Returns the identifier of the module.
   * It is server unique.
   * 
   * @return - module identifier
   */
  public Long getId();
  
  /**
   * The method returns the name of the module.
   * For example, the name of the resource module 
   * is used in the web interface.
   * 
   * @return - the name of the module
   */
  public String getName();
  
  /**
   * The method returns the type of the module.
   * The types are defined as constants.
   *  
   * @return - module type
   */
  public int getType();
  
  /**
   * The method returns the reference name.
   * That name can be <code>null</code> for the assignments.
   * The reference name for the resources points to the real name of the data file.
   * 
   * @return - the reference name which points to the real file name if available
   */
  public String getReferenceName();

  /**
   * The method returns the description of the module.
   * 
   * @return Moodle module description
   */
  public String getDescription();
  
  /**
   * Return the content of the module.
   * The method is useful for the resource modules.
   * 
   * @return - the module content
   * 
   * @throws ConnectorException if communication error is occurred
   */
  public InputStream getContent() throws ConnectorException;
  
  /**
   * The method sets the content of the module.
   * The content is sent to Moodle server synchronous.
   * 
   * @param contentFile - the new content of the module
   * 
   * @throws ConnectorException if communication error is occurred
   */
  public void setContent(File contentFile) throws ConnectorException;
  
  /**
   * The method return the course which contains that module.
   * 
   * @return - the module belongs to that course
   */
  public IMoodleCourse getCourse();
  
}
